const paths = require('./paths');
const autoprefixer = require('autoprefixer');
const pkgJson = require('../package.json');
const cssPrefix = pkgJson.cssPrefix || pkgJson.name;
const cssLoaderRule = {
  loader: 'css-loader',
  options: {
    modules: {
      mode: (resourcePath) => {
        if (resourcePath === paths.global) {
          return 'global';
        }
        return 'local';
      },
      localIdentName: `${cssPrefix}-[local]--[hash:base64:5]`,
    },
    sourceMap: true,
  },
};
const postCssLoaderRule = {
  loader: 'postcss-loader',
  options: {
    postcssOptions: {
      plugins: [
        autoprefixer({
          overrideBrowserslist: [
            'last 10 Chrome versions',
            'last 5 Firefox versions',
            'Safari >= 6',
            'ie> 8',
          ],
        }),
      ],
    },
  },
};
exports.postCssLoaderRule = postCssLoaderRule;
exports.cssLoaderRule = cssLoaderRule;
